import { createApp } from 'vue'
import { createStore } from 'vuex'
export default createStore({
    state() {
        return {
            map: null,
            pintMarker: null,
            infoWindow: null,
            scale:null
        }
    },
    mutations: {
        //保存地图对象
        SETMAP(state, value) {
            state.map = value
        },
        //点坐标信息
        SETMAKER(state, value) {
            state.pintMarker = value
        },
        //保存信息窗口
        SETINFOWINDOW(state, value) {
            state.infoWindow = value
        },
        //保存缩放比列
        SETSCALE(state,value){
            state.scale = value
        }
    },
    actions: {
        //清除页面的点坐标
        resetMap({ state,commit }) {
            //清除点坐标和信息框
            if (state.pintMarker) {
                state.pintMarker.forEach((item) => {
                    state.map.remove(item)
                })
            }
            if (state.infoWindow) {
                closeWindow()
                commit('SETINFOWINDOW',null)
            }
        }
    }
})